//package com.youlu.campus.admin.config;
//
//import com.youlu.campus.admin.base.CampusMQDefinition;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.Binding;
//import org.springframework.amqp.core.BindingBuilder;
//import org.springframework.amqp.core.CustomExchange;
//import org.springframework.amqp.core.Queue;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.HashMap;
//import java.util.Map;
//
//@Slf4j
//@Configuration
//public class RabbitDelayConfig {
//
//
//    @Value("${spring.profiles.active}")
//    private String env;
//
//    public String getQueue() {
//        return CampusMQDefinition.DELAY_QUEUE + "." + env;
//    }
//
//    public String getExchange() {
//        return CampusMQDefinition.DELAY_EXCHANGE + "." + env;
//    }
//
//    public String getRouting() {
//        return CampusMQDefinition.DELAY_ROUTING_KEY + "." + env;
//    }
//
//    @Bean
//    public Queue queue() {
//        return new Queue(getQueue());
//    }
//
//    // 配置默认的交换机
//    @Bean
//    CustomExchange customExchange() {
//        Map<String, Object> args = new HashMap<>();
//        args.put("x-delayed-type", "direct");
//        //参数二为类型：必须是x-delayed-message
//        return new CustomExchange(getExchange(), "x-delayed-message", true, false, args);
//    }
//
//    // 绑定队列到交换器
//    @Bean
//    Binding binding(Queue queue, CustomExchange exchange) {
//        return BindingBuilder.bind(queue).to(exchange).with(getRouting()).noargs();
//    }
//}
